package com.ruoyi.rural.service.impl;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.rural.domain.RuralHouse;
import com.ruoyi.rural.mapper.RuralHouseMapper;
import com.ruoyi.rural.service.IRuralHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * 房屋信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-02-06
 */
@Service
public class RuralHouseServiceImpl implements IRuralHouseService 
{
    @Autowired
    private RuralHouseMapper ruralHouseMapper;

    /**
     * 查询房屋信息
     * 
     * @param id 房屋信息主键
     * @return 房屋信息
     */
    @Override
    public RuralHouse selectRuralHouseById(String id)
    {
        return ruralHouseMapper.selectRuralHouseById(id);
    }

    /**
     * 查询房屋信息列表
     * 
     * @param ruralHouse 房屋信息
     * @return 房屋信息
     */
    @Override
    public List<RuralHouse> selectRuralHouseList(RuralHouse ruralHouse)
    {
        return ruralHouseMapper.selectRuralHouseList(ruralHouse);
    }

    /**
     * 新增房屋信息
     * 
     * @param ruralHouse 房屋信息
     * @return 结果
     */
    @Override
    public int insertRuralHouse(RuralHouse ruralHouse)
    {
        ruralHouse.setId(UUID.randomUUID().toString());
        ruralHouse.setCreateTime(DateUtils.getNowDate());
        return ruralHouseMapper.insertRuralHouse(ruralHouse);
    }

    /**
     * 修改房屋信息
     * 
     * @param ruralHouse 房屋信息
     * @return 结果
     */
    @Override
    public int updateRuralHouse(RuralHouse ruralHouse)
    {
        ruralHouse.setUpdateTime(DateUtils.getNowDate());
        return ruralHouseMapper.updateRuralHouse(ruralHouse);
    }

    /**
     * 批量删除房屋信息
     * 
     * @param ids 需要删除的房屋信息主键
     * @return 结果
     */
    @Override
    public int deleteRuralHouseByIds(String[] ids)
    {
        return ruralHouseMapper.deleteRuralHouseByIds(ids);
    }

    /**
     * 删除房屋信息信息
     * 
     * @param id 房屋信息主键
     * @return 结果
     */
    @Override
    public int deleteRuralHouseById(String id)
    {
        return ruralHouseMapper.deleteRuralHouseById(id);
    }
}
